package com.service.provide.controller;

import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 24466
 * @date 2024/9/22 15:27
 */
@RestController
public class ProdviderController {

    private final Environment environment;

    public ProdviderController(Environment environment) {
        this.environment = environment;
    }

    @RequestMapping(value = "/provider/{str}", method = RequestMethod.GET)
    public String echo(@PathVariable("str") String str) {
        // try {
        //     Thread.sleep(10000);
        // } catch (InterruptedException e) {
        //     throw new RuntimeException(e);
        // }

        for (int i = 0; i < 100; i++) {
            str += "测试数据测试数据测试数据测试数据测试数据测试数据测试数据测试数据";
        }

        return "this is "+ environment.getProperty("local.server.port") +". Hello Nacos Discovery: provider " + str;
    }
}
